import { getRatedApi } from "../../utils/api";

// 首页模块
const index = {
  namespaced: true,
  state: {
    // 首页相关
    ratedList: [],
  },
  mutations: {
    // 首页的最受欢迎列表
    getRatedList(state, payload) {
      state.ratedList = payload;
    },
  },
  actions: {
    // 最受欢迎列表接口
    getRatedListAsync({ commit }) {
      return new Promise((resolve) => {
        getRatedApi().then((res) => {
          if (res.status === 0) {
            commit("getRatedList", res.result);
            resolve();
          }
        });
      });
    },
  },
};

export default index;
